<!DOCTYPE html>
<html>

<head>
    <title>后台管理系统 </title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="__SKIN__/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="__SKIN__/css/admin.css"></script>
    <script src="__SKIN__/js/jquery.js"></script>
    <link href="__SKIN__/font-awesome/css/font-awesome.min.css" rel="stylesheet">
    <link href="__SKIN__/css/index.css" rel="stylesheet">
   
</head>

<body>



    <div class="msg"></div>
   

       

    <form action="/comm/wxpay/pay/?config_name=wx" method="POST">
      <input type="text" value="" name="openid" id="openid">
      <input type="text" value="t202003175170213" name="orderid">
      <input type="text" value="100" name="price">
      <input type="text" value="测试产品" name="title">
      <input type="text" value="/wx/index/index/" name="successurl">
      <input type="text" value="/wx/index/index/" name="failurl">

      <input type="submit" value="支付" >
    </form>
    <script>

       payjson=[];

        function onBridgeReady(){
        WeixinJSBridge.invoke(
            'getBrandWCPayRequest',payjson,
            function(res){
            if(res.err_msg == "get_brand_wcpay_request:ok" ){
            // 使用以上方式判断前端返回,微信团队郑重提示：
                    location.href='/h5.html#/setsx';
            }else{
                alert(JSON.stringify(res));
              
            }
        });
        }

        function silent(openid,orderid,title,price,successurl,failurl)
        {

  
                url="/comm/Wxpay/payjson/?config_name=wx";
                data={"orderid":orderid,"openid":openid,"title":title,"price":price,"successurl":successurl,"failurl":failurl};
                $.ajax({
                    type: "POST",
                    url: url,
                    data: data,
                    dataType: "JSON",
                    success: function (response) {
                        data=JSON.parse(response);
                        payjson=JSON.parse(data.json);
                        orderid=data.orderid;
                        if (typeof WeixinJSBridge == "undefined"){
                        if( document.addEventListener ){
                            document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
                        }else if (document.attachEvent){
                            document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
                            document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
                        }
                        }else{
                        onBridgeReady();
                        }
                    }
                });

        }

        function dodata(data)
        {
       
            if(data.url!=""){
                document.location.href=data.url;return; //没有登录，则转登录
            }
            if(data.code>0){
               
               $("#openid").val(data.openid);

               return;
              
                openid=data.openid;
                orderid="t202003175170213";
                title="测试产品";
                price=100;
                successurl=document.location.href;
                failurl=document.location.href;
                silent(openid,orderid,title,price,successurl,failurl);
            }
         
        }

  
    </script>
 <script src="/autologin/wxlogin/checkloginjsonp?config_name=wx&callback=dodata"></script>
</body>


</html>